<!--
 * @Author: ChunLai
 * @Date: 2022-08-25 16:05:33
 * @LastEditTime: 2025-09-04 17:22:53
 * @Description: 百年重庆告知
 * @FilePath: \02.bldinsure\src\views\healthy\chongqing\BaiNian.vue
-->
<template>
  <div class="healthy-wrap-cc bg-fff">
    <h3 v-if="configs.title">{{ configs.title }}</h3>
    <TipMsg :msg="configs.tips" v-if="configs.tips"></TipMsg>
    <div class="main-box pd14_lr">
      <!-- <div> -->
      <div class="sub-title">1_1、您和您家人已经获得的保险保障有哪些？</div>
      <div class="pd-l14 pdt6">
        <van-checkbox
          v-model="que1_1A"
          shape="square"
          checked-color="#f54040"
          icon-size="14px"
        >
          A.社会保险
        </van-checkbox>
        <div class="pd-l18" :key="`que1_1A${new Date().getTime()}`">
          <van-checkbox-group v-model="que1_1As" direction="horizontal">
            <van-checkbox
              shape="square"
              checked-color="#f54040"
              icon-size="14px"
              :name="item.value"
              v-for="(item, j) in que1_1AList"
              :key="`que1a-sub-${j}`"
            >
              {{ item.label }}
            </van-checkbox>
          </van-checkbox-group>
        </div>
        <van-checkbox
          v-model="que1_1B"
          shape="square"
          checked-color="#f54040"
          icon-size="14px"
        >
          B.商业保险
        </van-checkbox>
        <div class="pd-l18" :key="`que1_1B${new Date().getTime()}`">
          <van-checkbox-group v-model="que1_1Bs" direction="horizontal">
            <van-checkbox
              shape="square"
              checked-color="#f54040"
              icon-size="14px"
              :name="item.value"
              v-for="(item, j) in que1_1BList"
              :key="`que1b-sub-${j}`"
            >
              {{ item.label }}
            </van-checkbox>
          </van-checkbox-group>
        </div>
      </div>
      <!-- </div> -->
      <div v-if="que1_1B">
        <div class="sub-title">
          1_2、如果购买了商业保险，您和您家人每年共花费多少钱购买商业保险？
        </div>
        <div class="pd-l14 pdt6">
          <van-radio-group v-model="que1_2">
            <van-radio
              :name="opt.value"
              shape="square"
              checked-color="#f54040"
              icon-size="14px"
              v-for="(opt, j) in que1_2List"
              :key="`sub12-${j}`"
            >
              {{ opt.label }}
            </van-radio>
          </van-radio-group>
        </div>
      </div>
      <div v-if="que1_1B">
        <div class="sub-title">
          1_3、您和您家人现在每年用于购买商业保险的资金是否超过家庭年收入的20%？
        </div>
        <div class="pd-l14 pdt6">
          <van-radio-group v-model="que1_3">
            <van-radio
              :name="opt.value"
              shape="square"
              checked-color="#f54040"
              icon-size="14px"
              v-for="(opt, j) in que1_3List"
              :key="`sub12-${j}`"
            >
              {{ opt.label }}
            </van-radio>
          </van-radio-group>
        </div>
      </div>
      <!-- 第二题 -->
      <div class="sub-title">
        2、您和您的家人现在最需要购买哪些保障，每种保障赔付（给付）多少钱比较合适，保障期限多少年比较合适？
      </div>
      <div class="pd-l14 pdt6">
        <van-checkbox
          v-model="que2_A"
          shape="square"
          checked-color="#f54040"
          icon-size="14px"
        >
          A.身故和残疾保障
        </van-checkbox>
        <div class="pd-l30 md-inputs">
          <div class="input-main">
            <div class="input-box">
              <input
                class="md-input"
                type="number"
                onkeyup="this.value=this.value.replace(/\D/g,'')"
                placeholder="金额"
                v-model="que2_A_amnt"
              />
            </div>
            元
          </div>
          <div class="input-main mt6">
            <div class="input-box">
              <input
                class="md-input"
                type="number"
                placeholder="保障期限"
                v-model="que2_A_year"
              />
            </div>
            <div class="radios-box">
              <van-radio-group
                v-model="que2_A_year_unit"
                direction="horizontal"
              >
                <van-radio
                  v-for="(ele, idx) in que2List"
                  :key="`que2-year_unit-${idx}`"
                  :name="ele.value"
                  checked-color="#f54040"
                  icon-size="14px"
                >
                  {{ ele.label }}
                </van-radio>
              </van-radio-group>
            </div>
          </div>
        </div>
      </div>
      <div class="pd-l14 pdt6">
        <van-checkbox
          v-model="que2_B"
          shape="square"
          checked-color="#f54040"
          icon-size="14px"
        >
          B.重大疾病保障
        </van-checkbox>
        <div class="pd-l30 md-inputs">
          <div class="input-main">
            <div class="input-box">
              <input
                class="md-input"
                type="number"
                onkeyup="this.value=this.value.replace(/\D/g,'')"
                placeholder="金额"
                v-model="que2_B_amnt"
              />
            </div>
            元
          </div>
          <div class="input-main mt6">
            <div class="input-box">
              <input
                class="md-input"
                type="number"
                placeholder="保障期限"
                v-model="que2_B_year"
              />
            </div>
            <div class="radios-box">
              <van-radio-group
                v-model="que2_B_year_unit"
                direction="horizontal"
              >
                <van-radio
                  v-for="(ele, idx) in que2List"
                  :key="`que2-year_unit-${idx}`"
                  :name="ele.value"
                  checked-color="#f54040"
                  icon-size="14px"
                >
                  {{ ele.label }}
                </van-radio>
              </van-radio-group>
            </div>
          </div>
        </div>
      </div>
      <div class="pd-l14 pdt6">
        <van-checkbox
          v-model="que2_C"
          shape="square"
          checked-color="#f54040"
          icon-size="14px"
        >
          C.医疗费用保障
        </van-checkbox>
        <div class="pd-l30 md-inputs">
          <div class="input-main">
            <div class="input-box">
              <input
                class="md-input"
                type="number"
                onkeyup="this.value=this.value.replace(/\D/g,'')"
                placeholder="金额"
                v-model="que2_C_amnt"
              />
            </div>
            元
          </div>
          <div class="input-main mt6">
            <div class="input-box">
              <input
                class="md-input"
                type="number"
                placeholder="保障期限"
                v-model="que2_C_year"
              />
            </div>
            <div class="radios-box">
              <van-radio-group
                v-model="que2_C_year_unit"
                direction="horizontal"
              >
                <van-radio
                  v-for="(ele, idx) in que2List"
                  :key="`que2-year_unit-${idx}`"
                  :name="ele.value"
                  checked-color="#f54040"
                  icon-size="14px"
                >
                  {{ ele.label }}
                </van-radio>
              </van-radio-group>
            </div>
          </div>
        </div>
      </div>
      <div class="pd-l14 pdt6">
        <van-checkbox
          v-model="que2_D"
          shape="square"
          checked-color="#f54040"
          icon-size="14px"
        >
          D.教育金
        </van-checkbox>
        <div class="pd-l30 md-inputs">
          <div class="input-main">
            <div class="input-box">
              <input
                class="md-input"
                type="number"
                onkeyup="this.value=this.value.replace(/\D/g,'')"
                placeholder="金额"
                v-model="que2_D_amnt"
              />
            </div>
            元
          </div>
          <div class="input-main mt6">
            <div class="input-box">
              <input
                class="md-input"
                type="number"
                placeholder="保障期限"
                v-model="que2_D_year"
              />
            </div>
            <div class="radios-box">
              <van-radio-group
                v-model="que2_D_year_unit"
                direction="horizontal"
              >
                <van-radio
                  v-for="(ele, idx) in que2List"
                  :key="`que2-year_unit-${idx}`"
                  :name="ele.value"
                  checked-color="#f54040"
                  icon-size="14px"
                >
                  {{ ele.label }}
                </van-radio>
              </van-radio-group>
            </div>
          </div>
        </div>
      </div>
      <div class="pd-l14 pdt6">
        <van-checkbox
          v-model="que2_E"
          shape="square"
          checked-color="#f54040"
          icon-size="14px"
        >
          E.生存金返还
        </van-checkbox>
        <div class="pd-l30 md-inputs">
          <div class="input-main">
            <div class="input-box">
              <input
                class="md-input"
                type="number"
                onkeyup="this.value=this.value.replace(/\D/g,'')"
                placeholder="金额"
                v-model="que2_E_amnt"
              />
            </div>
            元
          </div>
          <div class="input-main mt6">
            <div class="input-box">
              <input
                class="md-input"
                type="number"
                placeholder="保障期限"
                v-model="que2_E_year"
              />
            </div>
            <div class="radios-box">
              <van-radio-group
                v-model="que2_E_year_unit"
                direction="horizontal"
              >
                <van-radio
                  v-for="(ele, idx) in que2List"
                  :key="`que2-year_unit-${idx}`"
                  :name="ele.value"
                  checked-color="#f54040"
                  icon-size="14px"
                >
                  {{ ele.label }}
                </van-radio>
              </van-radio-group>
            </div>
          </div>
        </div>
      </div>
      <div class="pd-l14 pdt6">
        <van-checkbox
          v-model="que2_F"
          shape="square"
          checked-color="#f54040"
          icon-size="14px"
        >
          F.年金/退休金收入保障
        </van-checkbox>
        <div class="pd-l30 md-inputs">
          <div class="input-main">
            <div class="input-box">
              <input
                class="md-input"
                type="number"
                onkeyup="this.value=this.value.replace(/\D/g,'')"
                placeholder="金额"
                v-model="que2_F_amnt"
              />
            </div>
            元/年
          </div>
          <div class="input-main mt6">
            <div class="input-box">
              <input
                class="md-input"
                type="number"
                placeholder="保障期限"
                v-model="que2_F_year"
              />
            </div>
            <div class="radios-box">
              <van-radio-group
                v-model="que2_F_year_unit"
                direction="horizontal"
              >
                <van-radio
                  v-for="(ele, idx) in que2List"
                  :key="`que2-year_unit-${idx}`"
                  :name="ele.value"
                  checked-color="#f54040"
                  icon-size="14px"
                >
                  {{ ele.label }}
                </van-radio>
              </van-radio-group>
            </div>
          </div>
        </div>
      </div>
      <!-- 第三题 -->
      <div class="sub-title">
        3、您是否希望所购买的保险具有投资功能？如果是，请选择您想购买的类型；如果否，请选择D
      </div>
      <div class="pd-l14 pdt6">
        <van-radio-group v-model="que3">
          <van-radio
            :name="opt.value"
            shape="square"
            checked-color="#f54040"
            icon-size="14px"
            v-for="(opt, j) in que3List"
            :key="`sub3-${j}`"
          >
            <div v-html="opt.label"></div>
          </van-radio>
        </van-radio-group>
      </div>
      <div class="sub-title">
        4、在对家庭生活不造成过大影响的情况下，您打算用多少钱购买保险？您愿意一次性交费，还是分期交费？
      </div>
      <!-- 第四题 -->
      <div
        class="pd-l14 pdt6 sub4-box"
        v-for="(opt, j) in que4List"
        :key="`sub4-${j}`"
      >
        <van-checkbox
          v-model="opt.checked"
          shape="square"
          icon-size="14px"
          checked-color="#f54040"
          @change="
            (e) => {
              changeCheckbox(e, `sub4-${opt.name}`);
            }
          "
        >
          {{ opt.label }}
        </van-checkbox>
        <div class="input-main">
          <div class="input-box">
            <input
              class="md-input"
              type="number"
              placeholder="交费金额"
              v-model="opt.inputCash"
            />
          </div>
          元 {{ opt.name === "B" ? "，" : "" }}
        </div>
        <div class="input-main pd-l20" v-if="opt.name === 'B'">
          能够持续交
          <div class="input-box w40">
            <input
              class="md-input"
              type="number"
              placeholder="缴费期间"
              v-model="opt.inputTime"
            />
          </div>
          年
        </div>
      </div>
      <!-- 第五题 -->
      <div class="sub-title">5、A.您是否了解本次投保现在的保障范围？</div>
      <div class="pd-l14 pdt6">
        <van-radio-group v-model="que5_A" direction="horizontal">
          <van-radio
            :name="opt.value"
            shape="square"
            checked-color="#f54040"
            icon-size="14px"
            v-for="(opt, j) in que5List"
            :key="`sub5A-${j}`"
          >
            <div v-html="opt.label"></div>
          </van-radio>
        </van-radio-group>
      </div>
      <div class="sub-title">
        5、B.您本次投保所缴保费是否在您的承受范围以内？
      </div>
      <div class="pd-l14 pdt6">
        <van-radio-group v-model="que5_B" direction="horizontal">
          <van-radio
            :name="opt.value"
            shape="square"
            checked-color="#f54040"
            icon-size="14px"
            v-for="(opt, j) in que5List"
            :key="`sub5A-${j}`"
          >
            <div v-html="opt.label"></div>
          </van-radio>
        </van-radio-group>
      </div>
    </div>
    <div class="foot-tips">
      提示：如果您在保障期满前需用钱而要求退还保险费，一般会有一些损失。不按期交费会导致保单失效。
    </div>
    <template v-if="!disabledEdit">
      <FooterBtns btnNum="1" @saveForm="nextStep()" />
    </template>
  </div>
</template>

<script>
import { mapGetters } from "vuex";

export default {
  name: "ChongQingBaiNian",
  data() {
    return {
      configs: {},
      que1_1A: true,
      que1_1As: ["b"],
      que1_1AList: [
        {
          label: "a工伤保险",
          value: "a",
        },
        {
          label: "b社会医疗保险",
          value: "b",
        },
        {
          label: "c社会养老保险",
          value: "c",
        },
      ],

      que1_1B: false,
      que1_1Bs: [],
      que1_1BList: [
        {
          label: "a意外险",
          value: "a",
        },
        {
          label: "b健康险",
          value: "b",
        },
        {
          label: "c人寿保险",
          value: "c",
        },
        {
          label: "d年金保险",
          value: "d",
        },
      ],

      que1_2: "",
      que1_2List: [
        {
          value: "A",
          label: "A.5000元以下",
        },
        {
          value: "B",
          label: "B.5000-10000元",
        },
        {
          value: "C",
          label: "C.10000-20000元",
        },
        {
          value: "D",
          label: "D.20000-50000元",
        },
        {
          value: "E",
          label: "E.50000元以上",
        },
      ],
      que1_3: "",
      que1_3List: [
        {
          value: "A",
          label: "A.超过",
        },
        {
          value: "B",
          label: "B.未超过",
        },
      ],

      que2_A: false,
      que2_A_amnt: "",
      que2_A_year: "",
      que2_A_year_unit: "",
      que2_B: false,
      que2_B_amnt: "",
      que2_B_year: "",
      que2_B_year_unit: "",
      que2_C: false,
      que2_C_amnt: "",
      que2_C_year: "",
      que2_C_year_unit: "",
      que2_D: false,
      que2_D_amnt: "",
      que2_D_year: "",
      que2_D_year_unit: "",
      que2_E: false,
      que2_E_amnt: "",
      que2_E_year: "",
      que2_E_year_unit: "",
      que2_F: false,
      que2_F_amnt: "",
      que2_F_year: "",
      que2_F_year_unit: "",
      que2List: [
        {
          value: "Y",
          label: "年",
        },
        {
          value: "A",
          label: "终身",
        },
      ],

      que3: "D",
      que3List: [
        {
          label:
            "A.分红保险：您可以每年分红，<b>但红利水平不确定</b>，如果保险公司没赚到钱，可能不分红。",
          value: "A",
        },
        {
          label:
            "B.万能保险：您可以从所交保险费中拿出一些钱，交给保险公司投资。投资收益率有最低保证，<b>但最低保证以上的收益不确定</b>。您的保险费被扣除一定初始费用和死亡风险保险费后，再交给保险公司投资，在投资过程中还可能定期被扣除一些保单管理费。",
          value: "B",
        },
        {
          label:
            "C.投资连结保险：您可以从所交保险费中拿出一些钱，交给保险公司投资，并根据自己的风险承受能力选择投资账户。投资回报不确定，可能赚钱或亏钱。您的保险费被扣除一些初始费用和死亡风险保险费后，再交给保险公司投资，在投资过程中还可能定期被扣除一些保单管理费和资产管理费。可投资保险费通过买入或卖出投资单位的方式进出投资账户，买入、卖出价格之间存在一定差价。",
          value: "C",
        },
        {
          label: "D.不看重投资功能",
          value: "D",
        },
      ],

      que4List: [
        {
          label: "A.一次性交",
          name: "A",
          checked: false,
          inputCash: "",
        },
        {
          label: "B.每年交",
          name: "B",
          checked: false,
          inputCash: "",
          inputTime: "",
        },
      ],

      que5_A: "是",
      que5_B: "是",
      que5List: [
        {
          value: "是",
          label: "是",
        },
        {
          value: "否",
          label: "否",
        },
      ],

      questionList: [],
      queryData: null, // 路由数据
      isShareNotice: false,
    };
  },
  components: {},
  computed: {
    ...mapGetters({
      showedRisks: "risks/showedRisks",
      totalPrem: "insert/totalPrem",
    }),
    cpQue1() {
      let res = "",
        reaArr2 = [];
      reaArr2 = this.que1_1AList.map((item) => {
        return this.que1_1As.includes(item.value) ? "是" : "否";
      });
      if (reaArr2.length > 0) {
        res = reaArr2.join(",");
      }
      return `${this.que1_1A ? "是" : "否"},${res}` || "";
    },
    cpQue2() {
      let res = "",
        reaArr2 = [];
      reaArr2 = this.que1_1BList.map((item) => {
        return this.que1_1Bs.includes(item.value) ? "是" : "否";
      });
      if (reaArr2.length > 0) {
        res = reaArr2.join(",");
      }
      return `${this.que1_1B ? "是" : "否"},${res}` || "";
    },
    cpQue3() {
      let res = "",
        reaArr2 = this.que1_2List.map((item) => {
          return item.value === this.que1_2 ? "是" : "否";
        });
      if (reaArr2.length > 0) {
        res = reaArr2.join(",");
      }
      return `${res}` || "";
    },
    cpQue4() {
      let res = "",
        reaArr2 = this.que1_3List.map((item) => {
          return item.value === this.que1_3 ? "是" : "否";
        });
      if (reaArr2.length > 0) {
        res = reaArr2.join(",");
      }
      return `${res}` || "";
    },
    cpQue5() {
      let res =
        this.que2_A_year_unit === "Y" ? `${this.que2_A_year}` : `null,是`;
      return `${this.que2_A ? "是" : "否"},${this.que2_A_amnt},${res}` || "";
    },
    cpQue6() {
      let res =
        this.que2_B_year_unit === "Y" ? `${this.que2_B_year}` : `null,是`;
      return `${this.que2_B ? "是" : "否"},${this.que2_B_amnt},${res}` || "";
    },
    cpQue7() {
      let res =
        this.que2_C_year_unit === "Y" ? `${this.que2_C_year}` : `null,是`;
      return `${this.que2_C ? "是" : "否"},${this.que2_C_amnt},${res}` || "";
    },
    cpQue8() {
      let res =
        this.que2_D_year_unit === "Y" ? `${this.que2_D_year}` : `null,是`;
      return `${this.que2_D ? "是" : "否"},${this.que2_D_amnt},${res}` || "";
    },
    cpQue9() {
      let res =
        this.que2_E_year_unit === "Y" ? `${this.que2_E_year}` : `null,是`;
      return `${this.que2_E ? "是" : "否"},${this.que2_E_amnt},${res}` || "";
    },
    cpQue10() {
      let res =
        this.que2_F_year_unit === "Y" ? `${this.que2_F_year}` : `null,是`;
      return `${this.que2_F ? "是" : "否"},${this.que2_F_amnt},${res}` || "";
    },
    cpQue11() {
      //3
      let res = "",
        reaArr2 = this.que3List.map((item) => {
          return item.value === this.que3 ? "是" : "否";
        });
      if (reaArr2.length > 0) {
        res = reaArr2.join(",");
      }
      return `${res}` || "";
    },
    cpQue12() {
      // 4_A
      const obj = this.que4List[0],
        res1 = obj.checked ? "是" : "否",
        res2 = obj.checked ? `${obj.inputCash}` : "null";
      return `${res1},${res2}` || "";
    },
    cpQue13() {
      // 4_B
      const obj = this.que4List[1],
        res1 = obj.checked ? "是" : "否",
        res2 = obj.checked ? `${obj.inputCash}` : "null",
        res3 = obj.checked ? `${obj.inputTime}` : "null";
      return `${res1},${res2},${res3}` || "";
    },
    cpQue14() {
      //5_A
      let res = "",
        reaArr2 = this.que5List.map((item) => {
          return item.value === this.que5_A ? "是" : "否";
        });
      if (reaArr2.length > 0) {
        res = reaArr2.join(",");
      }
      return `${res}` || "";
    },
    cpQue15() {
      //5_B
      let res = "",
        reaArr2 = this.que5List.map((item) => {
          return item.value === this.que5_B ? "是" : "否";
        });
      if (reaArr2.length > 0) {
        res = reaArr2.join(",");
      }
      return `${res}` || "";
    },
    isShareHealthy() {
      let res = false;
      if (this.$getDataFromUrl("share") == "1") {
        res = true;
      }
      return res;
    },
  },
  watch: {
    que1_1A(val) {
      if (!val) {
        this.que1_1As = [];
      }
    },
    que1_1As: {
      handler: function (val) {
        this.que1_1A = val.length > 0 ? true : false;
      },
      deep: true,
    },
    que1_1B(val) {
      if (!val) {
        this.que1_1Bs = [];
        this.que1_2 = "";
        this.que1_3 = "";
      }
    },
    que1_1Bs: {
      handler: function (val) {
        this.que1_1B = val.length > 0 ? true : false;
      },
      deep: true,
    },
    que4List: {
      handler: function (val) {
        if (!this.que4List[0].checked) {
          this.que4List[0].inputCash = "";
        }
        if (!this.que4List[1].checked) {
          this.que4List[1].inputCash = "";
          this.que4List[1].inputTime = "";
        }
      },
      deep: true,
    },
  },
  created() {
    const querys = this.$route.query || {};
    this.queryData = querys;
    /* === 2.分享页面 ===*/
    this.handlerRender();
  },
  mounted() {},
  methods: {
    // 获取健康告知相关数据
    handlerRender() {
      this.$store
        .dispatch("json/getNoticeJson", "chongqing")
        .then(async (res) => {
          this.configs = res;
          this.questionList = res.questionList;
          /**特殊题目设置*/
          const riskObj = this.showedRisks[0],
            mainPayYear = riskObj.payendyear,
            mainPayYearType = riskObj.payendyearType,
            totalFee = this.totalPrem || "";
          // 第4题
          if (mainPayYearType === "Y") {
            this.que4List[1].checked = true;
            this.que4List[1].inputCash = totalFee;
            this.que4List[1].inputTime =
              mainPayYear === "趸交" ? "1" : mainPayYear;
          } else {
            this.que4List[0].checked = true;
            this.que4List[0].inputCash = totalFee;
          }
          // 回显
          this.dataEcho();
        });
    },
    dataEcho() {
      this.$store
        .dispatch("apis/comAdminApiRequest", {
          apiParams: {
            ...this.apiComParams,
            type: "4",
          },
          apiName: "queryImparts",
        })
        .then((data) => {
          if (data.code == "1" && data.imparts.length > 0) {
            this.reBackForApi(data.imparts);
          }
        });
    },
    // 已填写数据回显
    reBackForApi(initDatas) {
      const len = initDatas.length;
      for (let i = 0; i < len; i++) {
        const item = initDatas[i],
          ansArr = item.ImpartParammodle.split(","),
          queCode = item.ImpartCode;
        if (["1_1A", "1_1B"].includes(queCode)) {
          this[`que${queCode}`] = ansArr[0] === "是";
          this[`que${queCode}s`] = this.apiToPageTrans(
            queCode,
            ansArr.slice(1)
          );
        } else if (["1_2", "1_3", "3"].includes(queCode)) {
          let arr2 = this.apiToPageTrans(queCode, ansArr);
          this[`que${queCode}`] = arr2[0] || "";
        } else if (queCode.indexOf("2_") !== -1) {
          this[`que${queCode}`] = ansArr[0] === "是" ? true : false;
          if (this[`que${queCode}`]) {
            this[`que${queCode}_amnt`] = ansArr[1] || "";
            this[`que${queCode}_year_unit`] = ansArr[2] == "null" ? "A" : "Y";
            if (ansArr[2] != "null") {
              this[`que${queCode}_year`] = ansArr[2] || "";
            }
          }
        } else if (queCode === "4_A") {
          this.que4List[0].checked = ansArr[0] === "是" ? true : false;
          this.que4List[0].inputCash = ansArr[1] === "null" ? "" : ansArr[1];
          this.que4List[0].inputTime = ansArr[2] === "是" ? true : false;
        } else if (queCode === "4_B") {
          this.que4List[1].checked = ansArr[0] === "是" ? true : false;
          this.que4List[1].inputCash = ansArr[1] === "null" ? "" : ansArr[1];
          this.que4List[1].inputTime = ansArr[2] === "null" ? "" : ansArr[2];
        } else if (queCode.indexOf("5_") !== -1) {
          let arr2 = this.apiToPageTrans("5", ansArr);
          this[`que${queCode}`] = arr2[0] || "";
        }
      }
    },
    apiToPageTrans(ImpartCode, ansArr) {
      let arr = this[`que${ImpartCode}List`].map((ele, index) => {
        return ansArr[`${index}`] === "是" ? ele.value : "";
      });
      return arr.filter((s) => s && s.trim());
    },
    changeCheckbox(e, typeVal) {
      if (typeVal === "sub4-A") {
        if (e) {
          this.$set(this.que4List[1], "checked", false);
          this.$set(this.que4List[1], "inputCash", "");
          this.$set(this.que4List[1], "inputTime", "");
        }
      } else if (typeVal === "sub4-B") {
        if (e) {
          this.$set(this.que4List[0], "checked", false);
          this.$set(this.que4List[0], "inputCash", "");
        }
      }
    },
    nextStep() {
      /* === 告知填写校验 === */
      const errtxt = "请回答告知";
      // 1
      if (!this.que1_1A && !this.que1_1B) {
        return this.$toast(`${errtxt}第 1_1 题`);
      } else if (this.que1_1A && this.que1_1As.length === 0) {
        return this.$toast(`请选择社会保险`);
      } else if (this.que1_1B) {
        if (this.que1_1Bs.length === 0) {
          return this.$toast(`请选择商业保险`);
        }
        if (this.que1_2 === "") {
          return this.$toast(`选择商业保险,请回答 1_2 题`);
        }
        if (this.que1_3 === "") {
          return this.$toast(`选择商业保险,请回答 1_3 题`);
        }
      } else if (this.que3 === "") {
        return this.$toast(`${errtxt}第 3 题`);
      } else if (!this.que4List[0].checked && !this.que4List[1].checked) {
        return this.$toast(`${errtxt}第 4 题`);
      } else if (this.que4List[0].checked && !this.que4List[0].inputCash) {
        return this.$toast(`请输入重庆告知（4_A）相关信息`);
      } else if (
        this.que4List[1].checked &&
        (!this.que4List[1].inputCash || !this.que4List[1].inputTime)
      ) {
        return this.$toast(`请输入重庆告知（4_B）相关信息`);
      } else if (this.que5_A !== "是") {
        return this.$toast(`重庆告知项第5_A题不能选否`);
      } else if (this.que5_B !== "是") {
        return this.$toast(`重庆告知项第5_B题不能选否`);
      }
      // 传值
      let quelist = this.questionList,
        len = quelist.length;
      for (let i = 0; i < len; i++) {
        const item = quelist[i];
        item.ImpartParammodle = this[`cpQue${i + 1}`];
      }
      this.$baseConfirm("以上内容是否为投保本人填写？", () => {
        this.submitToApi(quelist);
      });
    },
    submitToApi(quelist) {
      let params = {
        ...this.apiComParams,
        type: "4",
        imparts: quelist,
      };
      this.$store
        .dispatch("apis/comAdminApiRequest", {
          apiParams: params,
          apiName: "saveImparts",
          toast: true,
        })
        .then((data) => {
          if (data.code == "1") {
            if (this.isShareHealthy) {
              this.$baseAlert("提交成功", () => {
                this.$router.replace({
                  path: "/shareres?res=success",
                });
              });
            } else {
              this.$backRouter();
            }
          }
        });
    },
  },
};
</script>

<style lang="less" scoped>
@import "./style.less";
</style>
